/**
 * 
 */
package com.yerba.ricecooker.indicator.generic;

import com.yerba.ricecooker.quote.Quotes;
import com.yerba.ricecooker.utility.DataSet;

/**
 * @author mxie
 * 
 */
public abstract class Indicator<VALUE>
{
    public Indicator(Quotes quotes)
    {
        setQuotes(quotes);
    }

    private Quotes quotes = null;

    public Quotes getQuotes()
    {
        return quotes;
    }

    public void setQuotes(Quotes quotes)
    {
        this.quotes = quotes;
    }

    abstract public void calculate();
    abstract public String name();

    private DataSet<String, VALUE> values = new DataSet<String, VALUE>();

    public void add(String key, VALUE value)
    {
        values.insert(key, value);
    }

    public VALUE get(int index)
    {
        return values.getData(index);
    }

    public VALUE get(String key)
    {
        return values.getData(key);
    }

    public int index(String key)
    {
        return values.getDataIndex(key);
    }

    public int size()
    {
        return values.getSize();
    }
    
    public void clear()
    {
        values.clear();
    }

}
